<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>SQL: Add per-domain catch-all account</title>
        <link rel="stylesheet" type="text/css" href="./css/markdown.css" />
    </head>
    <body>

    <div id="navigation">
    <a href="https://www.iredmail.org" target="_blank">
        <img alt="iRedMail web site"
             src="./images/logo-iredmail.png"
             style="vertical-align: middle; height: 30px;"
             />&nbsp;
        <span>iRedMail</span>
    </a>
    &nbsp;&nbsp;//&nbsp;&nbsp;<a href="./index.html">Document Index</a></div><h1 id="sql-add-per-domain-catch-all-account">SQL: Add per-domain catch-all account</h1>
<div class="admonition attention">
<p class="admonition-title">Attention</p>
<ul>
<li>This document is applicable to iRedMail-0.9.7 and later releases.</li>
<li>Here's <a href="./sql.create.catch-all-20170701.html">doc for iRedMail-0.9.6 and earlier releases</a>.</li>
</ul>
</div>
<p>With default setting, iRedMail will reject emails sent to non-existing mail
accounts under hosted mail domains. If you want to accept these emails, you
need a domain catch-all account.</p>
<p>With MySQL/MariaDB or PostgreSQL backend, you can add catch-all account for
existing domain <code>domain.com</code> in SQL table <code>vmail.forwardings</code> like below:</p>
<pre><code class="language-sql">$ mysql -u root -p
sql&gt; USE vmail;
sql&gt; INSERT INTO forwardings (address, forwarding, domain, dest_domain)
                      VALUES ('domain.com', 'dest@example.com', 'domain.com', 'example.com');
</code></pre>
<p>This sql command creates catch-all address for domain <code>domain.com</code>, all mails
sent to non-existing accounts under <code>domain.com</code> will be delivered to
<code>dest@example.com</code>.</p>
<p><strong>NOTES</strong>:</p>
<ul>
<li>Address <code>dest@example.com</code> must exist.</li>
<li>With iRedAdmin-Pro, you can manage catch-all account in domain
  profile directly. Screenshot attached.</li>
</ul>
<p><img alt="" src="./images/iredadmin/domain_profile_catchall.png" /></p>
<h2 id="see-also">See also</h2>
<ul>
<li><a href="./ldap.add.catch-all.html">Add per-domain catch-all account for OpenLDAP backends</a></li>
</ul><div class="footer">
    <p style="text-align: center; color: grey;">All documents are available in <a href="https://github.com/iredmail/docs/">GitHub repository</a>, and published under <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">Creative Commons</a> license. You can <a href="https://github.com/iredmail/docs/archive/master.zip">download the latest version</a> for offline reading. If you found something wrong, please do <a href="https://www.iredmail.org/contact.html">contact us</a> to fix it.</p>
</div></body></html>